package com.awb.rabbitmqdemo.routing;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RoutingConfig {

    public static final String ROUTING_EXCHANGE = "routing_exchange";

    public static final String ROUTING_QUEUE_INFO = "routing_queue_info";
    
    public static final String ROUTING_QUEUE_ERROR = "routing_queue_error";
    
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(ROUTING_EXCHANGE);
    }

    @Bean
    public Queue queueInfo(){
        return new Queue(ROUTING_QUEUE_INFO);
    }

    @Bean
    public Queue queueError(){
        return new Queue(ROUTING_QUEUE_ERROR);
    }
    
    @Bean
    public Binding bindingInfo(){
        return BindingBuilder.bind(queueInfo()).to(directExchange()).with("info");
    }

    @Bean
    public Binding bindingError(){
        return BindingBuilder.bind(queueError()).to(directExchange()).with("error");
    }
    
    
    
    
}
